<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php /* @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Multi */ ?>
<?php $_option = $block->getOption(); ?>
<?php $_selections = $_option->getSelections(); ?>
<?php $_skipSaleableCheck = $this->helper('Magento\Catalog\Helper\Product')->getSkipSaleableCheck(); ?>
<div class="field admin__field <?php if ($_option->getRequired()) echo ' required' ?><?php if ($_option->getDecoratedIsLast()):?> last<?php endif; ?>">
    <label class="label admin__field-label"><span><?php echo $block->escapeHtml($_option->getTitle()) ?></span></label>
    <div class="control admin__field-control">
        <?php if (count($_selections) == 1 && $_option->getRequired()): ?>
            <?php /* @escapeNotVerified */ echo $block->getSelectionQtyTitlePrice($_selections[0]) ?>
            <input type="hidden" name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                   value="<?php /* @escapeNotVerified */ echo $_selections[0]->getSelectionId() ?>"
                   price="<?php /* @escapeNotVerified */ echo $block->getSelectionPrice($_selections[0]) ?>" />
        <?php else: ?>
            <select multiple="multiple" size="5" id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>"
                    name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>][]"
                    class="admin__control-multiselect bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> multiselect change-container-classname"
                    onchange="ProductConfigure.bundleControl.changeSelection(this)">
            <?php if(!$_option->getRequired()): ?>
                <option value=""><?php /* @escapeNotVerified */ echo __('None') ?></option>
            <?php endif; ?>
            <?php foreach ($_selections as $_selection): ?>
                <option value="<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"<?php if ($block->isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable() && !$_skipSaleableCheck) echo ' disabled="disabled"' ?> price="<?php /* @escapeNotVerified */ echo $block->getSelectionPrice($_selection) ?>"><?php /* @escapeNotVerified */ echo $block->getSelectionQtyTitlePrice($_selection, false) ?></option>
            <?php endforeach; ?>
            </select>
        <?php endif; ?>
    </div>
</div>
